package com.usian.ai.controller;

import com.usian.ai.common.Result;
import com.usian.ai.pojo.vo.InterviewerReqVo;
import com.usian.ai.pojo.vo.InterviewerSaveReqVo;
import com.usian.ai.pojo.vo.PageVo;
import com.usian.ai.service.InterviewerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 *
 * 控制面试官相关的操作，如添加面试官和列出面试官列表
 * @TODO:
 * @Author:baimu
 * @Date:2024 12 09 16 11
 **/

@RestController
@RequestMapping("/interviewer")
@CrossOrigin
@Slf4j
public class InterviewerController {


   final
   InterviewerService interviewerService;

   public InterviewerController(InterviewerService interviewerService) {
      this.interviewerService = interviewerService;
   }

   /**
    * 添加新面试官
    *
    * @param interviewerReqVo 经过验证的面试官请求对象，包含要添加的面试官的信息
    * @return 执行结果，包含操作是否成功的信息
    */
   @PostMapping("/addInterviewer")
   public Result addInterviewer(@RequestBody @Validated InterviewerSaveReqVo interviewerReqVo)
   {
       return interviewerService.addInterviewer(interviewerReqVo);
   }

   /**
    * 列出面试官列表
    *
    * @param pageVo 分页信息，包含当前页和每页大小等信息
    * @return 面试官列表和分页信息
    */
   @PostMapping("/listInterviewer")
   public Result listInterviewer(@RequestBody InterviewerReqVo interviewerReqVo )
   {
       log.debug("分页查询面试官列表，分页信息为：{}",interviewerReqVo);

       return interviewerService.listInterviewer(interviewerReqVo);
   }

   /**
    * 删除面试官
    * @param id
    * @return
    */
   @DeleteMapping("/deleteInterviewer/{id}")
   public Result deleteInterviewer(@PathVariable Integer id)
   {
      boolean b = interviewerService.removeById(id);
      return b?Result.ok():Result.fail();
   }
}

